Skip to main content

ComplexRewarderTime

The ComplexRewarderTime contract is a rewarder contract that can be used with MasterChefV2 or MiniChef to distribute a single extra reward token to multiple pools. Works by setting a rewardPerSecond on the contract to determine the number of reward tokens distributed every second, and uses allocation points for each pool to determine the ratio of distribution for each.

The full contract can be found here.

Functions

onSushiReward

function onSushiReward(uint256 pid, address _user, address to, uint256, uint256 lpToken) onlyMCV2 lock override external

Hook that is called from the MasterChefV2 or MiniChef contract to distribute the reward token to user that is harvesting SUSHI rewards.

Parameters

NameTypeDescription
piduint256pool ID of pool making the call
_useraddressaddress of user staked
toaddressaddress of where to send reward token
lpTokenuint256amount of LP token staked

pendingTokens

function pendingTokens(uint256 pid, address user, uint256) override external view returns (IERC20[] memory rewardTokens, uint256[] memory rewardAmounts)

View function to see pending reward tokens to harvest for a given user.

Parameters

NameTypeDescription
piduint256pool ID of pool rewarder is set to on chef contract
useraddressaddress of user staked

setRewardPerSecond

function setRewardPerSecond(uint256 _rewardPerSecond) public onlyOwner

Sets the reward per second to be distributed. Can only be called by the owner.

Be conscious of reward token decimals when setting this

Parameters

NameTypeDescription
_rewardPerSeconduint256the amount of reward tokens to be distributed per second

poolLength

function poolLength() public view returns (uint256 pools)

View functions that returns the number of pools added on this rewarder.

add

function add(uint256 allocPoint, uint256 _pid) public onlyOwner

Adds a new LP token to the rewarder. Can only be called by the owner.

Must be set to the same pid of pool on chef contract that this rewarder will be rewarding.

Parameters

NameTypeDescription
allocPointuint256number of allocation points assigned to pool
_piduint256pid of the pool on chef contracts

set

function set(uint256 _pid, uint256 _allocPoint) public onlyOwner

Update the given pool's allocation point. Can only be called by the owner.

Parameters

NameTypeDescription
_piduint256pid of the pool on chef contracts
_allocPointuint256number of allocation points assigned to pool

reclaimTokens

function reclaimTokens(address token, uint256 amount, address payable to) public onlyOwner

Allows owner to reclaim/withdraw any tokens (including reward tokens) held by the contract.

Parameters

NameTypeDescription
tokenaddresstoken address to reclaim, use 0x00 for ETH or native token
amountuint256amount of tokens to reclaim
toaddressreceiver of the reclaimed tokens

pendingToken

function pendingToken(uint256 _pid, address _user) public view returns (uint256 pending)

View function to see pending reward tokens.

Parameters

NameTypeDescription
_piduint256pool ID of pool rewarder is set to on chef contract
_useraddressaddress of user staked

massUpdatePools

function massUpdatePools(uint256[] calldata pids) external

Update reward variables for all pools passed in the pid array.

Parameters

NameTypeDescription
pidsuint256[]pool IDs of pools to update

updatePool

function updatePool(uint256 pid) public returns (PoolInfo memory pool)

Updates reward variables for the given pool and returns the pool that was updated.

Parameters

NameTypeDescription
piduint256pool ID of pool rewarder is set to on chef contract